/**
 * 角色管理用户配置页面JS
 * User: zhaoming
 * Date: 15-8-17
 * Time: 下午5:58
 * To change this template use File | Settings | File Templates.
 */
$(function(){
    //激活左侧导航菜单
    activeNavBar("MANAGE_ROLE_INFO");
    loadGrid();

    $("#resourceTab").click(function(){
        window.forward(springUrl+ "/web/roleInfo/resourceConfigPage?uniqueNo="+$("#uniqueNo").val());
    });
    $("#headGoBackBtn").click(function(){
        window.forward(springUrl+ "/web/roleInfo/index");
    });

    $("#queryBtn").click(function(){
        query();
    });

    $("#resetBtn").click(function(){
        $('#searchForm')[0].reset();
    });
});

/**
 * 加载数据列表
 */
function loadGrid() {
    var gridTable = jQuery("#gridTable");
    gridTable.jqGrid({
        mtype: "POST",
        url: springUrl + "/web/roleInfo/roleUserRelationPage",
        postData: {
            roleNo: $("#uniqueNo").val()
        },
        datatype: "json",
        autowidth: true,
        height: "100%",
        colModel: [
            {name:'',label:'用户账号', width:100, sortable: false, align:'center',
                formatter:function(cellValue, options, rowObject) {
                    var context = "";
                    if(rowObject.roleInfoVo.roleTypeCode == "1"){
                        context = rowObject.userInfoVo.userAccount;
                    }else if(rowObject.roleInfoVo.roleTypeCode == "2"){
                    }else if(rowObject.roleInfoVo.roleTypeCode == "3"){
                    }
                    return context;
                }
            },
            {name:'',label:'用户名称', width:100, sortable: false, align:'center',
                formatter:function(cellValue, options, rowObject) {
                    var context = "";
                    if(rowObject.roleInfoVo.roleTypeCode == "1"){
                        context = rowObject.userInfoVo.userName;
                    }else if(rowObject.roleInfoVo.roleTypeCode == "2"){
                    }else if(rowObject.roleInfoVo.roleTypeCode == "3"){
                    }
                    return context;
                }
            },
            {name:'roleInfoVo.roleTypeName',label:'角色类型', width:100, sortable: false, align:'center'}
        ],
        rownumbers: true,//添加左侧行号
        viewrecords: true,
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: "create_time",
        sortorder: "desc",
        altRows: true,
        pager: "#gridPager",
        jsonReader: { //server返回Json解析设定
            root: "content", //对于json中数据列表
            page: "pageNum",
            total: "total",
            records: "records"
        }
    });
    //navButtons
    gridTable.jqGrid('navGrid', "#employeeGridPager",
        {
            add: false,
            addicon: 'fa-plus purple',
            edit: false,
            editicon: 'fa-pencil blue',
            del: false,
            delicon: 'fa-trash red',
            view: false,
            viewicon: 'fa-search-plus orange',
            search: false,
            searchicon: 'fa-search grey',
            refresh: true,
            refreshicon: 'fa-refresh green'
        }
    );
    updatePagerIcons(this);
    resizeJqGrid("gridTable");
}